<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class SheetTemplate extends Model
{
    use HasFactory, SoftDeletes;

    const TYPE_REPORT = 1;
    const TYPE_AGGREGATE = 2;

    protected $casts = [
        'data' => 'json',
    ];

    protected $hidden = ['deleted_at'];

    public function aggregateTemplates()
    {
        return $this->belongsToMany(SheetTemplate::class, 'sheet_pivot', 'report_template_id', 'aggregate_template_id');
    }

    public function reportTemplates()
    {
        return $this->belongsToMany(SheetTemplate::class, 'sheet_pivot', 'aggregate_template_id', 'report_template_id');
    }
}
